package bjut.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author: zhuzhiming
 * @Date: 2022/4/21 21:21
 */
@Getter
@AllArgsConstructor
public enum SerializationTypeEnum {

    KRYO((byte) 0x01, "kryo"),
    PROTOSTUFF((byte) 0x02, "protostuff"),
    HESSIAN((byte) 0x03, "hessian");

    private final byte code;
    private final String type;

    public static String getSerialType(byte code) {
        for (SerializationTypeEnum type : SerializationTypeEnum.values()) {
            if (code == type.getCode()) {
                return type.getType();
            }
        }
        return null;
    }

}
